package com.boredom.Guts;

import java.util.Collection;
import java.util.LinkedList;

/**
 * A Group is either a User (just one person) or a Club (circle of friends).
 * Events are made by a Group, and shared either within the group,
 * or with the whole world.
 * Users are just Groups with no subgroups, while Clubs are groups
 * with subgroups.
 */

public class Group implements Serializable
{
    private String name;
    private Identity identity;

    private Collection<String> subgroups;
    
    public Group() {
    }

    public Group(String name) {
	this.name = name;
	this.identity = new Identity(); // generate keys
	this.subgroups = new LinkedList<String>();
    }

    public String getName() {
	return name;
    }

    public void add(String subgroup) {
	subgroups.add(subgroup);
    }

    public void remove(String subgroup) {
	subgroups.remove(subgroup);
    }

    public boolean hasChildren() {
	return !subgroups.isEmpty();
    }

    public Collection<String> getChildren() {
	return subgroups;
    }
}
